package fr.mehfile.view;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import fr.mehfile.R;
import fr.mehfile.gallerie.GallerieHandler;
import fr.mehfile.view.utils.Utils;

public class GallerieOnePhoto extends Activity implements View.OnClickListener  {
	
	private int currentImageView;
	private String albumName;
	
	@Override
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		setContentView(R.layout.gallerieonephoto);
		this.currentImageView = this.getIntent().getIntExtra("imageViewId", 0);
		albumName=this.getIntent().getStringExtra("albumName");
		
		TextView headerAlbum = (TextView) findViewById(R.id.header_album_text);
		headerAlbum.setText(albumName);
		
		final ImageView imageview = (ImageView) findViewById(R.id.gallerieonephoto);
		
		imageview.setImageResource(this.currentImageView);
		
		
		
		
		final GallerieHandler gallerieHandler = GallerieHandler.getInstance();
		
		ImageView precedent = (ImageView) findViewById(R.id.precedent);
		precedent.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				Utils.debugger.logDebug("one photo","currentImageView : " + currentImageView);
				Utils.debugger.logDebug("one photo","album name : " + albumName);
				currentImageView = gallerieHandler.getPreviousImageId(albumName,currentImageView);
				imageview.setImageResource(currentImageView);
			}
		});
		
		
		
		ImageView suivant = (ImageView) findViewById(R.id.suivant);
		suivant.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				Utils.debugger.logDebug("one photo","currentImageView : " + currentImageView);
				Utils.debugger.logDebug("one photo","album name : " + albumName);
				currentImageView = gallerieHandler.getNextImageId(albumName,currentImageView);
				imageview.setImageResource(currentImageView);
			}
		});
		
		
			
	}

	public void onClick(View arg0) {
		// TODO Auto-generated method stub
		
		
	}
	 @Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		this.getIntent().putExtra("imageViewId", this.currentImageView);
	}

}

